import { uuid } from "../util";
import { _BasicDataSource } from "../_BasicDataSource";
import { formarColor, GetCenter } from '../Config.js'

var TextColor = formarColor('#FFFFFF');
var BackgroundColor = formarColor('#000000aa');


var distance = function (a, b) {
    return Cesium.Cartesian3.distance(a, b);
}

var distanceArray = function (pointArray) {
    var M = 0;
    var length = pointArray.length;
    for (let i = 1; i < length; i++) {
        const a = pointArray[i];
        const b = pointArray[i - 1];
        M += distance(b, a);
    };
    return (M / 1000).toFixed(2);
}

var _distanceArray = function (pointArray) {
    var M = 0;
    var length = pointArray.length;
    for (let i = 1; i < length; i++) {
        const a = pointArray[i];
        const b = pointArray[i - 1];
        M += distance(b, a);
    };
    return M / 1000
}


var distanceLast = function (pointArray) {
    var M = distance(pointArray[pointArray.length - 3], pointArray[pointArray.length - 2]);
    return (M / 1000).toFixed(2);
};



class drawCircle {
    constructor(options = {}, parent) {
        this.EntityTypeName = 'MeasureEntity';
        this.id = options.id || uuid();
        this.Point = null;
        this.Entity = null;
        this.MovePoint = null;
        this.radius = 0;
        this.parent = parent;
        this.CenterLabel = null;
        this.radiusLabel = null;
        options = options || {};
        this.color = formarColor(options.color || parent.defaultOptions.color || "#19FFD85A");
        this.area = null;
        this.labelStatus = parent.defaultOptions.defaultNameStatus;
        this.FontSize = options.FontSize || 12;
    }
    set defaultNameStatus(value) {
        this.labelStatus == !!value;
        this.CenterLabel && (this.CenterLabel.show = !!value);
        this.radiusLabel && (this.radiusLabel.show = !!value)
    }
    get defaultNameStatus() {
        return this.labelStatus
    }
    destroy() {
        var RemoveObject = [];
        this.Entity && RemoveObject.push(this.Entity);
        this.Entity = null;
        this.CenterLabel && RemoveObject.push(this.CenterLabel);
        this.CenterLabel = null;
        this.radiusLabel && RemoveObject.push(this.radiusLabel);
        this.radiusLabel = null;
        this.parent.RemoveEntitys(RemoveObject);
    }
    movePosition(point) {
        if (this.Point) {
            var FontSize = window.REMFontSize || 1;
            this.MovePoint = point.cartesian;
            this.radius = Cesium.Cartesian3.distance(this.Point, this.MovePoint);
            this.area = ((this.radius / 1000) * (this.radius / 1000)) * Math.PI
            var area = '面积:' + this.area.toFixed(2) + 'k㎡';
            if (!this.CenterLabel) {
                this.CenterLabel = new Cesium.Entity({
                    position: this.Point,
                    _Source: this,
                    label: {
                        show: this.labelStatus,
                        font: parseInt(this.FontSize * FontSize) + 'pt Source Han Sans CN', //字体样式
                        showBackground: true, //是否显示背景颜色
                        style: Cesium.LabelStyle.FILL, //label样式
                        text: area,
                        verticalOrigin: Cesium.VerticalOrigin.CENTER, //垂直位置
                        horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平位置
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        fillColor: TextColor, //字体颜色
                        backgroundColor: BackgroundColor, //字体颜色
                    },
                });
                this.parent.AddEntitys([this.CenterLabel]);
            } else {
                this.CenterLabel.position = this.Point;
                this.CenterLabel.label.text = area;
            }

            if (!this.radiusLabel) {
                this.radiusLabel = new Cesium.Entity({
                    position: this.MovePoint,
                    _Source: this,
                    label: {
                        show: this.labelStatus,
                        font: parseInt(this.FontSize * FontSize) + 'pt Source Han Sans CN', //字体样式
                        showBackground: true, //是否显示背景颜色
                        style: Cesium.LabelStyle.FILL, //label样式
                        text: '半径:' + (this.radius / 1000).toFixed(2) + 'km',
                        verticalOrigin: Cesium.VerticalOrigin.CENTER, //垂直位置
                        horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平位置
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        fillColor: TextColor, //字体颜色
                        backgroundColor: BackgroundColor, //字体颜色
                    },
                });
                this.parent.AddEntitys([this.radiusLabel]);
            } else {
                this.radiusLabel.position = this.MovePoint;
                this.radiusLabel.label.text = '半径:' + (this.radius / 1000).toFixed(2) + 'km';
            }
        }
    }
    setPosition(point) {
        if (!this.Point) {
            this.Point = point.cartesian;
            var _update = () => {
                return this.radius ? this.radius : 1;
            }
            this.Entity = new Cesium.Entity({
                position: this.Point,
                _Source: this,
                ellipse: {
                    semiMinorAxis: new Cesium.CallbackProperty(_update, false),
                    semiMajorAxis: new Cesium.CallbackProperty(_update, false),
                    // 填充颜色
                    material: this.color
                }
            });
            this.parent.AddEntitys([this.Entity]);
        }
    }
    getValue(unit = 'km') {
        if (this.Point && this.radius && this.area) {
            var _data = this.parent.formatPostion(this.Point);
            var area = this.area
            if (unit == 'm') {
                area *= (1000 * 1000)
            }
            return {
                point: _data,
                radius: this.radius,
                area: area,
            };
        } else {
            throw new Error('绘制出错，无法获得对象数据');
        }
    }
}



class drawRectangle {
    constructor(options, parent) {
        this.EntityTypeName = 'MeasureEntity';
        this.id = uuid();
        this.Point = null;
        this.Entity = null;
        this.MovePoint = null;
        this.parent = parent;
        options = options || {};

        this.mouseLabel = null;
        this.XLabel = null;
        this.YLabel = null;

        this.color = formarColor(options.color || parent.defaultOptions.color || "#19FFD85A");
        this.area = null;
        this.labelStatus = parent.defaultOptions.defaultNameStatus;
        this.FontSize = options.FontSize || 12;
    }
    set defaultNameStatus(value) {
        this.labelStatus == !!value;
        this.mouseLabel && (this.mouseLabel.show = !!value);
        this.XLabel && (this.XLabel.show = !!value)
        this.YLabel && (this.YLabel.show = !!value)
    }
    get defaultNameStatus() {
        return this.labelStatus
    }
    destroy() {
        var RemoveObject = [];
        this.Entity && RemoveObject.push(this.Entity);
        this.Entity = null;
        this.mouseLabel && RemoveObject.push(this.mouseLabel);
        this.mouseLabel = null;
        this.XLabel && RemoveObject.push(this.XLabel);
        this.XLabel = null;
        this.YLabel && RemoveObject.push(this.YLabel);
        this.YLabel = null;
        this.parent.RemoveEntitys(RemoveObject);
    }
    movePosition(point) {
        if (this.Point) {
            var FontSize = window.REMFontSize || 1;
            this.MovePoint = point.cartesian;
            var Rectangle = Cesium.Rectangle.fromCartesianArray([this.Point, this.MovePoint]);

            var northwest = Cesium.Cartographic.toCartesian(Cesium.Rectangle.northwest(Rectangle));
            var northeast = Cesium.Cartographic.toCartesian(Cesium.Rectangle.northeast(Rectangle));
            var southwest = Cesium.Cartographic.toCartesian(Cesium.Rectangle.southwest(Rectangle));
            var southeast = Cesium.Cartographic.toCartesian(Cesium.Rectangle.southeast(Rectangle));
            var northCenter = GetCenter([northwest, northeast]);
            var _X = distance(northwest, northeast)
            var XLength = (_X / 1000).toFixed(2) + 'km';
            var westCenter = GetCenter([northwest, southwest]);
            var _Y = distance(northwest, southwest);
            var YLength = (_Y / 1000).toFixed(2) + 'km';
            this.area = (_X / 1000) * (_Y / 1000);
            var area = this.area.toFixed(2) + 'k㎡'
            var RectangleCenter = GetCenter([northwest, southeast]);

            if (!this.XLabel) {
                this.XLabel = new Cesium.Entity({
                    position: northCenter,
                    _Source: this,
                    label: {
                        show: this.labelStatus,
                        font: parseInt(this.FontSize * FontSize) + 'pt Source Han Sans CN', //字体样式
                        showBackground: true, //是否显示背景颜色
                        style: Cesium.LabelStyle.FILL, //label样式
                        text: (_X > _Y ? '长:' : '宽:') + XLength,
                        verticalOrigin: Cesium.VerticalOrigin.CENTER, //垂直位置
                        horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平位置
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        fillColor: TextColor, //字体颜色
                        backgroundColor: BackgroundColor, //字体颜色
                    },
                });
                this.parent.AddEntitys([this.XLabel]);
            } else {
                this.XLabel.label.text = (_X > _Y ? '长:' : '宽:') + XLength;
                this.XLabel.position = northCenter;
            }

            if (!this.YLabel) {
                this.YLabel = new Cesium.Entity({
                    position: westCenter,
                    _Source: this,
                    label: {
                        show: this.labelStatus,
                        font: parseInt(this.FontSize * FontSize) + 'pt Source Han Sans CN', //字体样式
                        showBackground: true, //是否显示背景颜色
                        style: Cesium.LabelStyle.FILL, //label样式
                        text: (_X < _Y ? '长:' : '宽:') + YLength,
                        verticalOrigin: Cesium.VerticalOrigin.CENTER, //垂直位置
                        horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平位置
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        fillColor: TextColor, //字体颜色
                        backgroundColor: BackgroundColor, //字体颜色
                    },
                });
                this.parent.AddEntitys([this.YLabel]);
            } else {
                this.YLabel.label.text = (_X < _Y ? '长:' : '宽:') + YLength;
                this.YLabel.position = westCenter;
            }

            if (!this.mouseLabel) {
                this.mouseLabel = new Cesium.Entity({
                    position: RectangleCenter,
                    _Source: this,
                    label: {
                        show: this.labelStatus,
                        font: parseInt(this.FontSize * FontSize) + 'pt Source Han Sans CN', //字体样式
                        showBackground: true, //是否显示背景颜色
                        style: Cesium.LabelStyle.FILL, //label样式
                        text: '面积:' + area,
                        verticalOrigin: Cesium.VerticalOrigin.TOP, //垂直位置
                        horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平位置
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        fillColor: TextColor, //字体颜色
                        pixelOffset: new Cesium.Cartesian2(0, 30), //偏移
                        backgroundColor: BackgroundColor, //字体颜色
                    },
                });
                this.parent.AddEntitys([this.mouseLabel]);
            } else {
                this.mouseLabel.label.text = '面积:' + area;
                this.mouseLabel.position = RectangleCenter;
            }


        }
    }
    setPosition(point) {
        if (!this.Point) {
            this.Point = point.cartesian;
            this.MovePoint = this.Point;
            var _update = () => {
                return Cesium.Rectangle.fromCartesianArray([this.Point, this.MovePoint]);
            }
            this.Entity = new Cesium.Entity({
                position: this.Point,
                _Source: this,
                rectangle: {
                    coordinates: new Cesium.CallbackProperty(_update, false),
                    material: this.color,
                    fill: true,
                }
            });
            this.parent.AddEntitys([this.Entity]);
        }
    }
    getValue(unit = 'km') {
        if (this.Point && this.MovePoint && this.area) {
            var area = this.area
            if (unit == 'm') {
                area *= (1000 * 1000)
            }
            return {
                points: [
                    this.parent.formatPostion(this.Point),
                    this.parent.formatPostion(this.MovePoint),
                ],
                area: area,
            };
        } else {
            throw new Error('绘制出错，无法获得对象数据');
        }
    }
}

class drawPolygon {
    constructor(options, parent) {
        this.EntityTypeName = 'MeasureEntity';
        this.id = uuid();
        this.Points = [];
        this.Entity = null;
        this.parent = parent;
        this.polylineEntity = null;
        this.polygonEntity = null;
        this.labelEntitys = [];
        this.mouseLabel = null;
        options = options || {};
        this.color = formarColor(options.color || parent.defaultOptions.color || "#19FFD85A");
        this.area = null;
        this.labelStatus = parent.defaultOptions.defaultNameStatus;
        this.FontSize = options.FontSize || 12;
    }
    set defaultNameStatus(value) {
        this.labelStatus == !!value;
        this.mouseLabel && (this.mouseLabel.show = !!value);
    }
    get defaultNameStatus() {
        return this.labelStatus
    }
    destroy() {
        var RemoveObject = [];
        this.polylineEntity && RemoveObject.push(this.polylineEntity);
        this.polylineEntity = null;
        this.polygonEntity && RemoveObject.push(this.polygonEntity);
        this.polygonEntity = null;
        this.mouseLabel && RemoveObject.push(this.mouseLabel);
        this.mouseLabel = null;
        this.parent.RemoveEntitys(RemoveObject);
    }
    movePosition(point) {
        if (this.Points.length > 1) {
            this.Points[this.Points.length - 1] = point.cartesian;
        }
        if (this.mouseLabel) {
            this.area = this.polgyonArea(this.Points) / 1000 / 1000;
            var area = this.area.toFixed(2);
            this.mouseLabel.label.text = '面积:' + area + 'k㎡';
            this.mouseLabel.position = point.cartesian;
        }
    }
    //计算多边形面积
    polgyonArea(points) {
        var area = 0;
        for (let i = 0; i < points.length; i++) {
            let j = (i + 1) % points.length;
            area += points[i].x * points[j].y;
            area -= points[i].y * points[j].x;
        }
        area /= 2;
        return Math.abs(area);
    }
    setPosition(point) {
        if (this.Points.length == 0) {
            this.Points.push(point.cartesian)
        } else {
            this.Points[this.Points.length - 1] = point.cartesian;
        };
        this.Points.push(point.cartesian);
        var _update = () => this.Points;
        if (!this.polylineEntity && !this.polygonEntity) {
            this.polylineEntity = new Cesium.Entity({
                position: this.Points[0],
                _Source: this,
                polyline: {
                    positions: new Cesium.CallbackProperty(_update, false),
                    material: this.color,
                    width: 2, // 宽度
                },
            });
            this.parent.AddEntitys([this.polylineEntity]);
        };
        var _polygonUpdate = () => {
            return { positions: this.Points };
        }
        if (this.Points.length >= 3 && !this.polygonEntity) {
            this.parent.RemoveEntitys([this.polylineEntity]);
            this.polylineEntity = null;
            this.polygonEntity = new Cesium.Entity({
                position: this.Points[0],
                _Source: this,
                polygon: {
                    hierarchy: new Cesium.CallbackProperty(_polygonUpdate, false),
                    material: this.color,
                    arcType: Cesium.ArcType.GEODESIC,
                },
            });
            this.parent.AddEntitys([this.polygonEntity]);
        }

        if (this.Points.length >= 3 && !this.mouseLabel) {
            var FontSize = window.REMFontSize || 1;
            this.mouseLabel = new Cesium.Entity({
                position: point.cartesian,
                _Source: this,
                label: {
                    show: this.labelStatus,
                    font: parseInt(this.FontSize * FontSize) + 'pt Source Han Sans CN', //字体样式
                    showBackground: true, //是否显示背景颜色
                    style: Cesium.LabelStyle.FILL, //label样式
                    verticalOrigin: Cesium.VerticalOrigin.TOP, //垂直位置
                    horizontalOrigin: Cesium.HorizontalOrigin.LEFT, //水平位置
                    pixelOffset: new Cesium.Cartesian2(20, -20), //偏移
                    disableDepthTestDistance: Number.POSITIVE_INFINITY,
                    fillColor: TextColor, //字体颜色
                    text: (this.polgyonArea(this.Points) / 1000 / 1000).toFixed(2) + 'k㎡',
                    backgroundColor: BackgroundColor, //字体颜色
                },
            });
            this.parent.AddEntitys([this.mouseLabel]);
        }
    }
    getValue(unit = 'km') {
        if (this.Points.length && this.area) {
            var points = [];
            this.Points.forEach(item => {
                if (item && points[points.length - 1]) {
                    var ans = Cesium.Cartesian3.equals(item, points[points.length - 1]);
                    !ans && points.push(item);
                } else {
                    points.push(item);
                }
            })
            var _point = [];
            points.forEach(item => {
                var _item = this.parent.formatPostion(item);
                _point.push(_item);
            })
            var _area = this.area;
            if (unit == 'm') {
                _area *= (1000 * 1000)
            }
            return {
                points: _point,
                area: _area
            };
        } else {
            throw new Error('绘制出错，无法获得对象数据');
        }
    }
}

class drawPolyline {
    constructor(options, parent) {
        this.EntityTypeName = 'MeasureEntity';
        this.id = uuid();
        this.Points = [];
        this.Entity = null;
        this.parent = parent;
        this.polylineEntity = null;
        this.labelEntitys = [];
        this.mouseLabel = null;
        options = options || {};
        this.color = formarColor(options.color || parent.defaultOptions.color || "#19FFD85A");
        this.labelStatus = parent.defaultOptions.defaultNameStatus;
        this.FontSize = options.FontSize || 12;
    }
    set defaultNameStatus(value) {
        this.labelStatus == value;
        this.mouseLabel && (this.mouseLabel.show = !!value);
        for (let i = 0; i < this.labelEntitys.length; i++) {
            const element = this.labelEntitys[i];
            element.show = !!value;
        }
    }
    get defaultNameStatus() {
        return this.labelStatus
    }
    destroy() {
        this.polylineEntity && this.parent.RemoveEntitys([this.polylineEntity]);
        this.polylineEntity = null;
        this.mouseLabel && this.parent.RemoveEntitys([this.mouseLabel]);
        this.polylineEntity = null;
        this.parent.RemoveEntitys(this.labelEntitys);
        this.labelEntitys = [];
    }
    movePosition(point) {
        if (this.Points.length > 1) {
            this.Points[this.Points.length - 1] = point.cartesian;
            if (!this.mouseLabel) {
                var FontSize = window.REMFontSize || 1;
                this.mouseLabel = new Cesium.Entity({
                    position: point.cartesian,
                    _Source: this,
                    label: {
                        show: this.labelStatus,
                        font: parseInt(this.FontSize * FontSize) + 'pt Source Han Sans CN', //字体样式
                        showBackground: true, //是否显示背景颜色
                        style: Cesium.LabelStyle.FILL, //label样式
                        verticalOrigin: Cesium.VerticalOrigin.TOP, //垂直位置
                        horizontalOrigin: Cesium.HorizontalOrigin.LEFT, //水平位置
                        pixelOffset: new Cesium.Cartesian2(20, -20), //偏移
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        fillColor: TextColor, //字体颜色
                        backgroundColor: BackgroundColor, //字体颜色
                    },
                });
                this.parent.AddEntitys([this.mouseLabel]);
            } else {
                this.mouseLabel.position = point.cartesian;
                var M = distanceArray(this.Points);
                this.mouseLabel.label.text = '总距离 ：' + M + 'km';
            }
        }
    }
    setPosition(point) {
        if (this.Points.length == 0) {
            this.Points.push(point.cartesian)
        } else {
            this.Points[this.Points.length - 1] = point.cartesian;
        };
        this.Points.push(point.cartesian);
        var _update = () => this.Points;
        if (!this.polylineEntity) {
            this.polylineEntity = new Cesium.Entity({
                position: this.Points[0],
                _Source: this,
                polyline: {
                    positions: new Cesium.CallbackProperty(_update, false),
                    material: this.color,
                    width: 2, // 宽度
                },
            });
            this.parent.AddEntitys([this.polylineEntity]);
        };
        if (this.Points.length > 2) {
            var FontSize = window.REMFontSize || 1;
            var M = distanceLast(this.Points);
            if (M != '0.00') {
                var _label = new Cesium.Entity({
                    position: GetCenter([this.Points[this.Points.length - 3], this.Points[this.Points.length - 2]]),
                    _Source: this,
                    label: {
                        show: this.labelStatus,
                        font: parseInt(this.FontSize * FontSize) + 'pt Source Han Sans CN', //字体样式
                        showBackground: true, //是否显示背景颜色
                        style: Cesium.LabelStyle.FILL, //label样式
                        text: M + 'km',
                        verticalOrigin: Cesium.VerticalOrigin.CENTER, //垂直位置
                        horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平位置
                        disableDepthTestDistance: Number.POSITIVE_INFINITY,
                        fillColor: TextColor, //字体颜色
                        backgroundColor: BackgroundColor, //字体颜色
                    },
                });
                this.labelEntitys.push(_label);
                this.parent.AddEntitys([_label]);
            }
        }
    }

    getValue(unit = 'km') {
        if (this.Points.length) {
            var points = [];
            this.Points.forEach(item => {
                if (item && points[points.length - 1]) {
                    var ans = Cesium.Cartesian3.equals(item, points[points.length - 1]);
                    !ans && points.push(item);
                } else {
                    points.push(item);
                }
            })
            var _point = [];
            points.forEach(item => {
                var _item = this.parent.formatPostion(item);
                _point.push(_item);
            })
            var length = _distanceArray(this.Points);
            if (unit == 'm') {
                length *= 1000;
            };
            return {
                points: _point,
                length: length,
            };
        } else {
            throw new Error('绘制出错，无法获得对象数据');
        }
    }
}

var drawObject = {
    circle: drawCircle,
    rectangle: drawRectangle,
    polygon: drawPolygon,
    polyline: drawPolyline
};


class MeasureDataSource extends _BasicDataSource {
    constructor(parent, options = {}) {
        super(uuid(), parent, options);
        this.EntityTypeName = 'MeasureEntity'
        this.defaultOptions = options;
        if (options.hasOwnProperty('defaultNameStatus')) {
            this.defaultOptions.defaultNameStatus = !!options.defaultNameStatus;
        } else {
            this.defaultOptions.defaultNameStatus = true;
        }
        this.CacheEvent = null;

    }
    set defaultNameStatus(value) {
        this.defaultOptions.defaultNameStatus = !!value;
        this.EachMapping((item) => {
            item.defaultNameStatus = !!value;
        });
    }
    get defaultNameStatus() {
        return this.defaultOptions.defaultNameStatus
    }
    /**
     * 开启量算事件
     *
     * @param {String} type 类型
     * @param {Object} options 绘制选项
     * @memberof MeasureDataSource
     */
    start(type, options, event) {
        this.stop();
        if (this.parent && drawObject[type]) {
            this.status = true;
            // this.CatchEvent = event;
            this.parent.on('Click', this.setPosition, this);
            this.parent.on('DBLClick', this.endPosition, this);
            this.parent.on('MouseMove', this.movePosition, this);
            this.CatchObject = new drawObject[type](options, this);
            this.CatchEvent = event;
            return this.CatchObject;
        } else {
            console.error('请将图层添加到地图中')
        }
    }

    /**
     * 结束量算事件
     *
     * @memberof MeasureDataSource
     */
    stop() {
        this.parent.off('Click', this.setPosition);
        this.parent.off('DBLClick', this.endPosition);
        this.parent.off('MouseMove', this.movePosition, this);
        if (this.CatchObject) {
            this.CatchObject.destroy();
            this.CatchObject = null;
            this.CatchEvent = null;
        }
        this.status = false;
    }

    /**
     * 左键点击取点事件
     *
     * @param {*} point
     * @memberof MeasureDataSource
     */
    setPosition(point) {
        if (this.status) {
            this.CatchObject.setPosition(point);
        };
    }

    /**
     * 双击地图，阻断事件
     *
     * @memberof MeasureDataSource
     */
    endPosition() {
        if (this.CatchObject) {
            this._Mapping[this.CatchObject.id] = this.CatchObject;
            // var points = this.CatchObject.getValue();
            this.CatchEvent && this.CatchEvent(this.CatchObject);
            this.CatchObject = null;
            this.CatchEvent = null;
        }
        this.stop();
    }

    /**
     * 鼠标移动事件
     *
     * @param {*} point
     * @memberof MeasureDataSource
     */
    movePosition(point) {
        this.CatchObject.movePosition(point);
    }

    /**
     * 自定义注销事件
     * 
     * @description 其他注销方法，统一由 _BasicDataSource 执行
     * @memberof MeasureDataSource
     */
    _destroy() {
        this.stop();
    }
}


export { MeasureDataSource }